<?php
// Load the QCubed Development Framework
require('../qcubed.inc.php');


class RoleListForm extends QForm {
    protected $dtgRoles;
    protected $AuthSys;
// Create QForm Event Handlers as Needed

//		protected function Form_Exit() {}
//		protected function Form_Load() {}
//		protected function Form_PreRender() {}
//		protected function Form_Validate() {}

    protected function Form_Run() {
// Security check for ALLOW_REMOTE_ADMIN
        $this->AuthSys = new Perm();
        $this->AuthSys->IsAdmin(true);
    }


    protected function Form_Create() {
// Instantiate the Meta DataGrid

        $this->dtgRoles = new RoleDataGrid($this);

// Style the DataGrid (if desired)
        $this->dtgRoles->CssClass = 'datagrid';
        $this->dtgRoles->AlternateRowStyle->CssClass = 'alternate';

// Add Pagination (if desired)
        $this->dtgRoles->Paginator = new QPaginator($this->dtgRoles);
        $this->dtgRoles->ItemsPerPage = 20;

// Use the MetaDataGrid functionality to add Columns for this datagrid

// Create an Edit Column
        $this->dtgRoles->RowActionParameterHtml = '<?= QS_ENCODE($_ITEM->Id) ?>';
        $this->dtgRoles->AddRowAction(new QClickEvent(), new QAjaxAction('dtgRoles_Click'));
        $this->dtgRoles->AddRowAction(new QMouseOverEvent(), new QCssClassAction('selectedStyle'));
        $this->dtgRoles->AddRowAction(new QMouseOutEvent(), new QCssClassAction());

// Create the Other Columns (note that you can use strings for role's properties, or you
// can traverse down QQN::role() to display fields that are down the hierarchy)
        $this->dtgRoles->MetaAddColumn('Name');
        $this->dtgRoles->MetaAddColumn('Active');
    }
    protected function dtgRoles_Click($strFormId, $strControlId, $strParameter) {
        $intId = $strParameter;
        $strEditPageUrl =  __SECURITY__. '/role_edit.php/'. $intId;

        QApplication::Redirect($strEditPageUrl);

    }
}
// Go ahead and run this form object to generate the page and event handlers, implicitly using
// role_list.tpl.php as the included HTML template file
RoleListForm::Run('RoleListForm',"tpl/role_list.tpl.php");
?>